(function(){"use strict";BX.namespace("BX.SidePanel");var e=null;Object.defineProperty(BX.SidePanel,"Instance",{enumerable:false,get:function(){var t=BX.PageObject.getRootWindow();if(t!==window){return t.BX.SidePanel.Instance}if(e===null){e=new BX.SidePanel.Manager({})}return e}});BX.SidePanel.Manager=function(e){this.anchorRules=[];this.anchorBinding=true;this.openSliders=[];this.lastOpenSlider=null;this.opened=false;this.hidden=false;this.hacksApplied=false;this.pageUrl=this.getCurrentUrl();this.pageTitle=this.getCurrentTitle();this.titleChanged=false;this.fullScreenSlider=null;this.handleAnchorClick=this.handleAnchorClick.bind(this);this.handleDocumentKeyDown=this.handleDocumentKeyDown.bind(this);this.handleWindowResize=BX.throttle(this.handleWindowResize,300,this);this.handleWindowScroll=this.handleWindowScroll.bind(this);this.handleTouchMove=this.handleTouchMove.bind(this);this.handleSliderOpenStart=this.handleSliderOpenStart.bind(this);this.handleSliderOpenComplete=this.handleSliderOpenComplete.bind(this);this.handleSliderCloseStart=this.handleSliderCloseStart.bind(this);this.handleSliderCloseComplete=this.handleSliderCloseComplete.bind(this);this.handleSliderLoad=this.handleSliderLoad.bind(this);this.handleSliderDestroy=this.handleSliderDestroy.bind(this);this.handleEscapePress=this.handleEscapePress.bind(this);this.handleFullScreenChange=this.handleFullScreenChange.bind(this);BX.addCustomEvent("SidePanel:open",this.open.bind(this));BX.addCustomEvent("SidePanel:close",this.close.bind(this));BX.addCustomEvent("SidePanel:closeAll",this.closeAll.bind(this));BX.addCustomEvent("SidePanel:destroy",this.destroy.bind(this));BX.addCustomEvent("SidePanel:hide",this.hide.bind(this));BX.addCustomEvent("SidePanel:unhide",this.unhide.bind(this));BX.addCustomEvent("SidePanel:postMessage",this.postMessage.bind(this));BX.addCustomEvent("SidePanel:postMessageAll",this.postMessageAll.bind(this));BX.addCustomEvent("SidePanel:postMessageTop",this.postMessageTop.bind(this));BX.addCustomEvent("BX.Bitrix24.PageSlider:close",this.close.bind(this));BX.addCustomEvent("Bitrix24.Slider:postMessage",this.handlePostMessageCompatible.bind(this))};var t=null;BX.SidePanel.Manager.registerSliderClass=function(e){if(BX.type.isNotEmptyString(e)){t=e}};BX.SidePanel.Manager.getSliderClass=function(){var e=t!==null?BX.getClass(t):null;return e!==null?e:BX.SidePanel.Slider};BX.SidePanel.Manager.prototype={open:function(e,t){if(!BX.type.isNotEmptyString(e)){return false}e=this.refineUrl(e);if(this.isHidden()){this.unhide()}var i=this.getTopSlider();if(i){if(i.isOpen()&&i.getUrl()===e){return false}}var n=null;if(this.getLastOpenSlider()&&this.getLastOpenSlider().getUrl()===e){n=this.getLastOpenSlider()}else{if(typeof t==="undefined"){var r=this.getUrlRule(e);t=r&&r.options?r.options:t}var l=BX.SidePanel.Manager.getSliderClass();n=new l(e,t);var s=null;if(n.getWidth()===null&&n.getCustomLeftBoundary()===null){s=0;var o=this.getLastOffset();if(i&&o!==null){s=Math.min(o+this.getMinOffset(),this.getMaxOffset())}}n.setOffset(s);if(i&&i.getCustomRightBoundary()!==null){const e=n.calculateRightBoundary();if(e>i.getCustomRightBoundary()){n.setCustomRightBoundary(i.getCustomRightBoundary())}}BX.addCustomEvent(n,"SidePanel.Slider:onOpenStart",this.handleSliderOpenStart);BX.addCustomEvent(n,"SidePanel.Slider:onBeforeOpenComplete",this.handleSliderOpenComplete);BX.addCustomEvent(n,"SidePanel.Slider:onCloseStart",this.handleSliderCloseStart);BX.addCustomEvent(n,"SidePanel.Slider:onBeforeCloseComplete",this.handleSliderCloseComplete);BX.addCustomEvent(n,"SidePanel.Slider:onLoad",this.handleSliderLoad);BX.addCustomEvent(n,"SidePanel.Slider:onDestroy",this.handleSliderDestroy);BX.addCustomEvent(n,"SidePanel.Slider:onEscapePress",this.handleEscapePress)}if(!this.isOpen()){this.applyHacks(n)}var d=n.open();if(!d){this.resetHacks(n)}return d},isOpen:function(){return this.opened},close:function(e,t){var i=this.getTopSlider();if(i){i.close(e,t)}},closeAll:function(e){var t=this.getOpenSliders();for(var i=t.length-1;i>=0;i--){var n=t[i];var r=n.close(e);if(!r){break}}},hide:function(){if(this.hidden){return false}var e=this.getTopSlider();this.getOpenSliders().forEach((function(e){e.hide()}));this.hidden=true;this.resetHacks(e);return true},unhide:function(){if(!this.hidden){return false}this.getOpenSliders().forEach((function(e){e.unhide()}));this.hidden=false;setTimeout(function(){this.applyHacks(this.getTopSlider())}.bind(this),0);return true},isHidden:function(){return this.hidden},destroy:function(e){if(!BX.type.isNotEmptyString(e)){return}e=this.refineUrl(e);var t=this.getSlider(e);if(this.getLastOpenSlider()&&(t||this.getLastOpenSlider().getUrl()===e)){this.getLastOpenSlider().destroy()}if(t!==null){var i=this.getOpenSliders();for(var n=i.length-1;n>=0;n--){var r=i[n];r.destroy();if(r===t){break}}}},reload:function(){var e=this.getTopSlider();if(e){e.reload()}},getTopSlider:function(){var e=this.openSliders.length;return this.openSliders[e-1]?this.openSliders[e-1]:null},getPreviousSlider:function(e){var t=null;var i=this.getOpenSliders();e=e||this.getTopSlider();for(var n=i.length-1;n>=0;n--){var r=i[n];if(r===e){t=i[n-1]?i[n-1]:null;break}}return t},getSlider:function(e){e=this.refineUrl(e);var t=this.getOpenSliders();for(var i=0;i<t.length;i++){var n=t[i];if(n.getUrl()===e){return n}}return null},getSliderByWindow:function(e){var t=this.getOpenSliders();for(var i=0;i<t.length;i++){var n=t[i];if(n.getFrameWindow()===e){return n}}return null},getOpenSliders:function(){return this.openSliders},getOpenSlidersCount:function(){return this.openSliders.length},addOpenSlider:function(e){if(!(e instanceof BX.SidePanel.Slider)){throw new Error("Slider is not an instance of BX.SidePanel.Slider")}this.openSliders.push(e)},removeOpenSlider:function(e){var t=this.getOpenSliders();for(var i=0;i<t.length;i++){var n=t[i];if(n===e){this.openSliders.splice(i,1);return true}}return false},getLastOpenSlider:function(){return this.lastOpenSlider},setLastOpenSlider:function(e){if(this.lastOpenSlider!==e){if(this.lastOpenSlider){this.lastOpenSlider.destroy()}this.lastOpenSlider=e}},resetLastOpenSlider:function(){if(this.lastOpenSlider&&this.getTopSlider()!==this.lastOpenSlider){this.lastOpenSlider.destroy()}this.lastOpenSlider=null},adjustLayout:function(){this.getOpenSliders().forEach((function(e){e.adjustLayout()}))},getLastOffset:function(){var e=this.getOpenSliders();for(var t=e.length-1;t>=0;t--){var i=e[t];if(i.getOffset()!==null){return i.getOffset()}}return null},refineUrl:function(e){if(BX.type.isNotEmptyString(e)&&e.match(/IFRAME/)){return BX.util.remove_url_param(e,["IFRAME","IFRAME_TYPE"])}return e},getPageUrl:function(){return this.pageUrl},getCurrentUrl:function(){return window.location.pathname+window.location.search+window.location.hash},getPageTitle:function(){return this.pageTitle},getCurrentTitle:function(){var e=document.title;if(BX.IM){e=e.replace(/^\([0-9]+\) /,"")}return e},enterFullScreen:function(){if(!this.getTopSlider()||this.getFullScreenSlider()){return}var e=document.body;if(e.requestFullscreen){BX.bind(document,"fullscreenchange",this.handleFullScreenChange);e.requestFullscreen()}else if(e.webkitRequestFullScreen){BX.bind(document,"webkitfullscreenchange",this.handleFullScreenChange);e.webkitRequestFullScreen()}else if(e.msRequestFullscreen){BX.bind(document,"MSFullscreenChange",this.handleFullScreenChange);e.msRequestFullscreen()}else if(e.mozRequestFullScreen){BX.bind(document,"mozfullscreenchange",this.handleFullScreenChange);e.mozRequestFullScreen()}else{console.log("Slider: Full Screen mode is not supported.")}},exitFullScreen:function(){if(!this.getFullScreenSlider()){return}if(document.exitFullscreen){document.exitFullscreen()}else if(document.webkitExitFullscreen){document.webkitExitFullscreen()}else if(document.msExitFullscreen){document.msExitFullscreen()}else if(document.mozCancelFullScreen){document.mozCancelFullScreen()}},getFullScreenElement:function(){return document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||null},getFullScreenSlider:function(){return this.fullScreenSlider},handleFullScreenChange:function(e){if(this.getFullScreenElement()){this.fullScreenSlider=this.getTopSlider();BX.addClass(this.fullScreenSlider.getOverlay(),"side-panel-fullscreen");this.fullScreenSlider.fireEvent("onFullScreenEnter")}else{if(this.getFullScreenSlider()){BX.removeClass(this.getFullScreenSlider().getOverlay(),"side-panel-fullscreen");this.fullScreenSlider.fireEvent("onFullScreenExit");this.fullScreenSlider=null}BX.unbind(document,e.type,this.handleFullScreenChange);window.scrollTo(0,this.pageScrollTop);setTimeout(function(){this.adjustLayout();var e=document.createEvent("Event");e.initEvent("resize",true,true);window.dispatchEvent(e)}.bind(this),1e3)}},postMessage:function(e,t,i){var n=this.getSliderFromSource(e);if(!n){return}var r=null;var l=this.getOpenSliders();for(var s=l.length-1;s>=0;s--){var o=l[s];if(o===n){r=l[s-1]?l[s-1]:null;break}}var d=r&&r.getWindow()||window;d.BX.onCustomEvent("Bitrix24.Slider:onMessage",[o,i]);var a=new BX.SidePanel.MessageEvent({sender:n,slider:r?r:null,data:i,eventId:t});if(r){r.firePageEvent(a);r.fireFrameEvent(a)}else{BX.onCustomEvent(window,a.getFullName(),[a])}},postMessageAll:function(e,t,i){var n=this.getSliderFromSource(e);if(!n){return}var r=null;var l=this.getOpenSliders();for(var s=l.length-1;s>=0;s--){var o=l[s];if(o===n){continue}r=new BX.SidePanel.MessageEvent({sender:n,slider:o,data:i,eventId:t});o.firePageEvent(r);o.fireFrameEvent(r)}r=new BX.SidePanel.MessageEvent({sender:n,slider:null,data:i,eventId:t});BX.onCustomEvent(window,r.getFullName(),[r])},postMessageTop:function(e,t,i){var n=this.getSliderFromSource(e);if(!n){return}var r=new BX.SidePanel.MessageEvent({sender:n,slider:null,data:i,eventId:t});BX.onCustomEvent(window,r.getFullName(),[r])},getMinOffset:function(){return 63},getMaxOffset:function(){return this.getMinOffset()*3},bindAnchors:function(e){e=e||{};if(BX.type.isArray(e.rules)&&e.rules.length){if(this.anchorRules.length===0){window.document.addEventListener("click",this.handleAnchorClick,true)}if(!(e.rules instanceof Object)){console.error("BX.SitePanel: anchor rules were created in a different context. "+"This might be a reason for a memory leak.");console.trace()}e.rules.forEach(function(e){if(BX.type.isArray(e.condition)){for(var t=0;t<e.condition.length;t++){if(BX.type.isString(e.condition[t])){e.condition[t]=new RegExp(e.condition[t],"i")}}}e.options=BX.type.isPlainObject(e.options)?e.options:{};if(BX.type.isNotEmptyString(e.loader)&&!BX.type.isNotEmptyString(e.options.loader)){e.options.loader=e.loader;delete e.loader}this.anchorRules.push(e)}.bind(this))}},isAnchorBinding:function(){return this.anchorBinding},enableAnchorBinding:function(){this.anchorBinding=true},disableAnchorBinding:function(){this.anchorBinding=false},handleSliderOpenStart:function(e){if(!e.isActionAllowed()){return}var t=e.getSlider();if(t.isDestroyed()){return}if(this.getTopSlider()){this.exitFullScreen();this.getTopSlider().hideOverlay();var i=this.getTopSlider().getOffset()===t.getOffset()&&this.getTopSlider().getWidth()===t.getWidth()&&this.getTopSlider().getCustomLeftBoundary()===t.getCustomLeftBoundary();if(!i){this.getTopSlider().showShadow()}this.getTopSlider().hideOrDarkenCloseBtn();this.getTopSlider().hidePrintBtn();this.getTopSlider().hideExtraLabels()}else{t.setOverlayAnimation(true)}this.addOpenSlider(t);this.getOpenSliders().forEach((function(e,t,i){e.getLabel().moveAt(i.length-t-1)}),this);this.losePageFocus();if(!this.opened){this.pageUrl=this.getCurrentUrl();this.pageTitle=this.getCurrentTitle()}this.opened=true;this.resetLastOpenSlider()},handleSliderOpenComplete:function(e){this.setBrowserHistory(e.getSlider());this.updateBrowserTitle()},handleSliderCloseStart:function(e){if(!e.isActionAllowed()){return}if(e.getSlider()&&e.getSlider().isDestroyed()){return}var t=this.getPreviousSlider();var i=this.getTopSlider();this.exitFullScreen();this.getOpenSliders().forEach((function(e,t,i){e.getLabel().moveAt(i.length-t-2)}),this);if(t){t.unhideOverlay();t.hideShadow();t.showOrLightenCloseBtn();if(i){i.hideOverlay();i.hideShadow()}}},handleSliderCloseComplete:function(e){var t=e.getSlider();if(t===this.getTopSlider()){this.setLastOpenSlider(t)}this.cleanUpClosedSlider(t)},handleSliderDestroy:function(e){var t=e.getSlider();BX.removeCustomEvent(t,"SidePanel.Slider:onOpenStart",this.handleSliderOpenStart);BX.removeCustomEvent(t,"SidePanel.Slider:onBeforeOpenComplete",this.handleSliderOpenComplete);BX.removeCustomEvent(t,"SidePanel.Slider:onCloseStart",this.handleSliderCloseStart);BX.removeCustomEvent(t,"SidePanel.Slider:onBeforeCloseComplete",this.handleSliderCloseComplete);BX.removeCustomEvent(t,"SidePanel.Slider:onLoad",this.handleSliderLoad);BX.removeCustomEvent(t,"SidePanel.Slider:onDestroy",this.handleSliderDestroy);BX.removeCustomEvent(t,"SidePanel.Slider:onEscapePress",this.handleEscapePress);var i=e.getSlider().getFrameWindow();if(i){i.document.removeEventListener("click",this.handleAnchorClick,true)}if(t===this.getLastOpenSlider()){this.lastOpenSlider=null}this.cleanUpClosedSlider(t)},handleEscapePress:function(e){if(this.isOnTop()&&this.getTopSlider()){if(this.getTopSlider().canCloseByEsc()){this.getTopSlider().close()}}},cleanUpClosedSlider:function(e){this.removeOpenSlider(e);e.unhideOverlay();e.hideShadow();this.getOpenSliders().forEach((function(e,t,i){e.getLabel().moveAt(i.length-t-1)}),this);if(this.getTopSlider()){this.getTopSlider().showOrLightenCloseBtn();this.getTopSlider().unhideOverlay();this.getTopSlider().hideShadow();this.getTopSlider().showExtraLabels();if(this.getTopSlider().isPrintable()){this.getTopSlider().showPrintBtn()}this.getTopSlider().focus()}else{window.focus()}if(!this.getOpenSlidersCount()){this.resetHacks(e);this.opened=false}this.resetBrowserHistory();this.updateBrowserTitle()},handleSliderLoad:function(e){var t=e.getSlider().getFrameWindow();if(t){t.document.addEventListener("click",this.handleAnchorClick,true)}this.setBrowserHistory(e.getSlider());this.updateBrowserTitle()},handlePostMessageCompatible:function(e,t){this.postMessage(e,"",t)},getSliderFromSource:function(e){if(e instanceof BX.SidePanel.Slider){return e}else if(BX.type.isNotEmptyString(e)){return this.getSlider(e)}else if(e!==null&&e===e.window&&window!==e){return this.getSliderByWindow(e)}return null},applyHacks:function(e){if(this.hacksApplied){return false}e&&e.applyHacks();this.disablePageScrollbar();this.bindEvents();e&&e.applyPostHacks();this.hacksApplied=true;return true},resetHacks:function(e){if(!this.hacksApplied){return false}e&&e.resetPostHacks();this.enablePageScrollbar();this.unbindEvents();e&&e.resetHacks();this.hacksApplied=false;return true},bindEvents:function(){BX.bind(document,"keydown",this.handleDocumentKeyDown);BX.bind(window,"resize",this.handleWindowResize);BX.bind(window,"scroll",this.handleWindowScroll);if(BX.browser.IsMobile()){BX.bind(document.body,"touchmove",this.handleTouchMove)}},unbindEvents:function(){BX.unbind(document,"keydown",this.handleDocumentKeyDown);BX.unbind(window,"resize",this.handleWindowResize);BX.unbind(window,"scroll",this.handleWindowScroll);if(BX.browser.IsMobile()){BX.unbind(document.body,"touchmove",this.handleTouchMove)}},disablePageScrollbar:function(){var e=window.innerWidth-document.documentElement.clientWidth;document.body.style.paddingRight=e+"px";BX.addClass(document.body,"side-panel-disable-scrollbar");this.pageScrollTop=window.pageYOffset||document.documentElement.scrollTop},enablePageScrollbar:function(){document.body.style.removeProperty("padding-right");BX.removeClass(document.body,"side-panel-disable-scrollbar")},losePageFocus:function(){if(BX.type.isDomNode(document.activeElement)){document.activeElement.blur()}},handleDocumentKeyDown:function(e){if(e.keyCode!==27){return}e.preventDefault();if(this.isOnTop()&&this.getTopSlider()){if(this.getTopSlider().canCloseByEsc()){this.getTopSlider().close()}}},handleWindowResize:function(){this.adjustLayout()},handleWindowScroll:function(){window.scrollTo(0,this.pageScrollTop);this.adjustLayout()},handleTouchMove:function(e){e.preventDefault()},isOnTop:function(){var e=document.documentElement.clientWidth/2;var t=document.documentElement.clientHeight/2;var i=document.elementFromPoint(e,t);return BX.hasClass(i,"side-panel")||BX.findParent(i,{className:"side-panel"})!==null},extractLinkFromEvent:function(e){e=e||window.event;var t=e.target;if(e.which!==1||!BX.type.isDomNode(t)||e.ctrlKey||e.metaKey){return null}var i=t;if(t.nodeName!=="A"){i=BX.findParent(t,{tag:"A"},1)}if(!BX.type.isDomNode(i)){return null}var n=i.getAttribute("href");if(n){return{url:n,anchor:i,target:i.getAttribute("target")}}return null},handleAnchorClick:function(e){if(!this.isAnchorBinding()){return}var t=this.extractLinkFromEvent(e);if(!t||BX.data(t.anchor,"slider-ignore-autobinding")){return}if(BX.data(e.target,"slider-ignore-autobinding")){return}var i=this.getUrlRule(t.url,t);if(!this.isValidLink(i,t)){return}if(BX.type.isFunction(i.handler)){i.handler(e,t)}else{e.preventDefault();this.open(t.url,i.options)}},emulateAnchorClick:function(e){var t={url:e,anchor:null,target:null};var i=this.getUrlRule(e,t);if(!this.isValidLink(i,t)){BX.reload(e)}else if(BX.type.isFunction(i.handler)){i.handler(new Event("slider",{bubbles:false,cancelable:true}),t)}else{this.open(t.url,i.options)}},getUrlRule:function(e,t){if(!BX.type.isNotEmptyString(e)){return null}for(var i=0;i<this.anchorRules.length;i++){var n=this.anchorRules[i];if(!BX.type.isArray(n.condition)){continue}for(var r=0;r<n.condition.length;r++){var l=e.match(n.condition[r]);if(l&&!this.hasStopParams(e,n.stopParameters)){if(t){t.matches=l}return n}}}return null},isValidLink:function(e,t){if(!e){return false}if(e.allowCrossDomain!==true&&BX.ajax.isCrossDomain(t.url)){return false}if(e.mobileFriendly!==true&&BX.browser.IsMobile()){return false}if(BX.type.isFunction(e.validate)&&!e.validate(t)){return false}return true},setBrowserHistory:function(e){if(!(e instanceof BX.SidePanel.Slider)){return}if(e.canChangeHistory()&&e.isOpen()&&e.isLoaded()){window.history.replaceState({},"",e.getUrl())}},resetBrowserHistory:function(){var e=null;var t=this.getOpenSliders();for(var i=t.length-1;i>=0;i--){var n=t[i];if(n.canChangeHistory()&&n.isOpen()&&n.isLoaded()){e=n;break}}var r=e?e.getUrl():this.getPageUrl();if(r){window.history.replaceState({},"",r)}},updateBrowserTitle:function(){var e=null;var t=this.getOpenSliders();for(var i=t.length-1;i>=0;i--){e=this.getBrowserTitle(t[i]);if(BX.type.isNotEmptyString(e)){break}}if(BX.type.isNotEmptyString(e)){document.title=e;this.titleChanged=true}else if(this.titleChanged){document.title=this.getPageTitle();this.titleChanged=false}},getBrowserTitle:function(e){if(!e||!e.canChangeTitle()||!e.isOpen()||!e.isLoaded()){return null}var t=e.getTitle();if(!t&&!e.isSelfContained()){t=e.getFrameWindow()?e.getFrameWindow().document.title:null}return BX.type.isNotEmptyString(t)?t:null},hasStopParams:function(e,t){if(!t||!BX.type.isArray(t)||!BX.type.isNotEmptyString(e)){return false}var i=e.indexOf("?");if(i===-1){return false}var n=e.substring(i);for(var r=0;r<t.length;r++){var l=t[r];if(n.match(new RegExp("[?&]"+l+"=","i"))){return true}}return false},getLastOpenPage:function(){return this.getLastOpenSlider()},getCurrentPage:function(){return this.getTopSlider()}}})();
//# sourceMappingURL=manager.map.js